/****** MP3.h *****************************************************
 *
 * Tyler Fultz
 * 1/15/13
 *
 **********************************************************************/
//MP3 Codec Register Macros
#define SCI_MODE_ADDR   	0x00
#define SCI_CLOCKF_ADDR 	0x03
#define SCI_VOL_ADDR    	0x0B
#define SCI_BASS_ADDR   	0x02
#define SCI_AUDDATA_ADDR 	0x05
 
 // Pins for interfacing with SCI/SDI over SPI bus to MP3 Module
#define DREQ 			_RA4
#define MP3_CS 			_LATA7
#define BSYNC 			_LATG12
#define MP3_RST 		_LATA5
#define BSYNC 			_LATG12

 //Tri-states for Pins interfacing with SCI/SDI 
#define DREQ_DIR 		_TRISA4
#define MP3_CS_DIR		_TRISA7
#define BSYNC_DIR 		_TRISG12
#define MP3_RST_DIR             _TRISA5
#define BSYNC_DIR 		_TRISG12

//Command Codes for MP3 Codec
#define WRITE_CODE 0x02
#define READ_CODE  0x03

//Various Macros
#define hi(a) 			((a>>8)&0x00FF)
#define lo(a) 			(a&0x00FF)


//External Variables
extern unsigned const char Danger[];

 //Structure Type
typedef struct{

	unsigned const char* Name;
	uint16 Size;
	char String[10];
	
}MP3File;

 //Initialization Functions
void MP3Init(void); //Initialization of codec for MP3 Playback

 //MP3 Functions
void MP3SoftReset(void);    //Software reset of MP3 Player
void InitMP3Files(void);    //Initialize Code MP3 files

//SPI Functions
void SCI_Spi2Write(uint8 ADDR, uint16 DataIn);
void SCI_Spi2Read(uint8 start_address, uint8 num_words, uint16 *data_buffer);
void SDI_Spi2Write(uint8 *data, uint16 num_bytes, uint8 zerowrite);
